<?php
class Actions {

	const FUNCTION_NAME = "function";
	const PARAMETERS_NAME = "parameters";

	const FUNCTION_GET_LOCALIZATION = "Localization.get";
	const FUNCTION_SET_LOCALIZATION = "Localization.set";

	const FUNCTION_IS_LOGGED_IN = "User.isLoggedIn";
	const FUNCTION_LOG_IN = "User.logIn";
	const FUNCTION_AUTOMATIC_LOG_OUT = "User.automaticLogOut";
	const FUNCTION_LOG_OUT = "User.logOut";
	const FUNCTION_UPDATE_USER = "User.update";
	const FUNCTION_EDIT_USER = "EditUser.editPassword";
	const FUNCTION_CREATE_USER = "NewUser.register";
	const FUNCTION_SEARCH_USERS = "usersPanel.searchResult";
	const FUNCTION_GET_USER = "usersPanel.getDetails";
	const FUNCTION_GET_ANKETARI = "anketariPanel.searchResult";
	const FUNCTION_UPDATE_ANKETARI = "EditAnketari.editKontrolor";

	const FUNCTION_INSERT_DOBIJENI = "NewForm.insertDobijeni";
	const FUNCTION_SEARCH_FORMS = "formsPanel.searchResult";
	const FUNCTION_GET_FORMS = "formsPanel.getDetails";
	const FUNCTION_UPDATE_FORMS = "formsChooser.insertDobijeni";
	const FUNCTION_INSERT_REMARK = "NewRemark.insert";
	const FUNCTION_SELECT_REMARK = "Remarks.get";

	const FUNCTION_SEARCH_RETURNED = "returnedFormsPanel.searchResult";
	const FUNCTION_GET_RETURNED = "returnedFormsPanel.getDetails";
	const FUNCTION_UPDATE_RETURNED = "returnedChooser.insertDobijeni";

	const FUNCTION_SEARCH_KONTROLA = "kontrolaFormsPanel.searchResult";
	const FUNCTION_GET_KONTROLA = "kontrolaFormsPanel.getDetails";
	const FUNCTION_UPDATE_KONTROLA = "kontrolaChooser.insertDobijeni";
	const FUNCTION_POTVRDI_KONTROLA = "kontrolaChooser.potvrdi";
	const FUNCTION_VRATI_KONTROLA = "kontrolaChooser.vrati";
	const FUNCTION_VRATI_SVE_KONTROLA = "kontrolaChooser.vratiSve";

	final static function switchAction() {
		switch ($_REQUEST[self::FUNCTION_NAME]) {
			case self::FUNCTION_SET_LOCALIZATION:
				Headers::printJSON(Localization::getInstance()->set());
				break;
			case self::FUNCTION_GET_LOCALIZATION:
				Headers::printJSON(json_encode(Localization::getInstance()->get()));
				break;
			case self::FUNCTION_IS_LOGGED_IN:
			case self::FUNCTION_AUTOMATIC_LOG_OUT:
				Headers::printJSON(json_encode(User::checkIfLoggedIn()));
				break;
			case self::FUNCTION_LOG_IN:
				Headers::printJSON(json_encode(User::logIn()));
				break;
			case self::FUNCTION_LOG_OUT:
				Headers::printJSON(json_encode(User::logOut()));
				break;
			case self::FUNCTION_CREATE_USER:
				Headers::printJSON(json_encode(User::createUser()));
				break;
			case self::FUNCTION_UPDATE_USER:
			case self::FUNCTION_EDIT_USER:
				Headers::printJSON(json_encode(User::updateUserPassword()));
				break;
			case self::FUNCTION_SEARCH_USERS:
				Headers::printJSON(json_encode(User::getAllUsers()));
				break;
			case self::FUNCTION_GET_USER:
				Headers::printJSON(json_encode(User::getUserById()));
				break;
			case self::FUNCTION_GET_ANKETARI:
				Headers::printJSON(json_encode(User::getAllAnketari()));
				break;
			case self::FUNCTION_UPDATE_ANKETARI:
				Headers::printJSON(json_encode(User::setKontrolorForAnketar()));
				break;
			case self::FUNCTION_INSERT_DOBIJENI:
			case self::FUNCTION_UPDATE_FORMS:
			case self::FUNCTION_UPDATE_RETURNED:
			case self::FUNCTION_UPDATE_KONTROLA:
				Headers::printJSON(json_encode(User::iuOsobaWithStatus()));
				break;
			case self::FUNCTION_SEARCH_FORMS:
				Headers::printJSON(json_encode(User::searchPersons()));
				break;
			case self::FUNCTION_GET_FORMS:
			case self::FUNCTION_GET_RETURNED:
			case self::FUNCTION_GET_KONTROLA:
				Headers::printJSON(json_encode(User::getPersonById()));
				break;
			case self::FUNCTION_SEARCH_RETURNED:
				Headers::printJSON(json_encode(User::getDeclinedPerson()));
				break;
			case self::FUNCTION_SEARCH_KONTROLA:
				Headers::printJSON(json_encode(User::getPersonsByControlor()));
				break;
			case self::FUNCTION_POTVRDI_KONTROLA:
				Headers::printJSON(json_encode(User::verifyPersonSuccess()));
				break;
			case self::FUNCTION_VRATI_KONTROLA:
				Headers::printJSON(json_encode(User::verifyPersonReturn()));
				break;
			case self::FUNCTION_VRATI_SVE_KONTROLA:
				Headers::printJSON(json_encode(User::denyAnketarPersons()));
				break;
			case self::FUNCTION_INSERT_REMARK:
				Headers::printJSON(json_encode(User::addZakljucak()));
				break;
			case self::FUNCTION_SELECT_REMARK:
				Headers::printJSON(json_encode(User::getAllZakljucak()));
				break;
		}
	}
}